package com.a3dweijing.wetouch2.Util;

import android.content.Context;

import com.a3dweijing.wetouch2.Activity.PasswordLoginActivity;
import com.a3dweijing.wetouch2.Common.CallBack;
import com.a3dweijing.wetouch2.tools.*;
import com.netease.nimlib.sdk.NIMClient;
import com.netease.nimlib.sdk.RequestCallback;
import com.netease.nimlib.sdk.auth.AuthService;
import com.netease.nimlib.sdk.auth.LoginInfo;

/**
 * Created by Administrator on 2018/4/8.
 */

public class ImUtil
{
    /**
     * im登录 展示未用
     * 
     * @param pwd
     */
    private void loginIm(final String pwd, final Context context, final CallBack callBack)
    {
        LoginInfo info = new LoginInfo("11", "187e9cef4d637e4565ab6bfa63666006"); // config...
        RequestCallback<LoginInfo> callback = new RequestCallback<LoginInfo>()
        {
            @Override
            public void onSuccess(LoginInfo param)
            {
                com.a3dweijing.wetouch2.tools.SharedPreUtil.put(context, "imname", param.getAccount());
                com.a3dweijing.wetouch2.tools.SharedPreUtil.put(context, "imtoken", param.getToken());
                callBack.doNext(0, param);
            }
            
            @Override
            public void onFailed(int code)
            {
                callBack.doNext(-1, code);
            }
            
            @Override
            public void onException(Throwable exception)
            {
                callBack.doNext(-2, exception);
            }
        };
        NIMClient.getService(AuthService.class).login(info).setCallback(callback);
    }
}
